package com.jsjosem.aftersales.request;

import androidx.core.util.Consumer;

import com.jsjosem.aftersales.api.ProductApi;
import com.jsjosem.aftersales.data.response.PageResponse;
import com.jsjosem.aftersales.data.response.ProductResponse;

import retrofit2.Call;

public class ProductRequest extends AsyncRequest<PageResponse<ProductResponse>> {

    /*
     *
     * 获取产品数据
     * */
    public void products(int page, int per_page, Consumer<PageResponse<ProductResponse>> success, Consumer<? super Object> failed) {
        ProductApi request = retrofit.create(ProductApi.class);
        Call<PageResponse<ProductResponse>> products = request.products(page, per_page);
        sendRequest(products, success, failed);
    }

    public void getCustomerProducts(int id, Consumer<PageResponse<ProductResponse>> success, Consumer<? super Object> failed) {
        ProductApi request = retrofit.create(ProductApi.class);
        Call<PageResponse<ProductResponse>> customerProducts = request.getCustomerProducts(id);
        sendRequest(customerProducts, success, failed);
    }

}
